<?php
function site_redirct($location, $status=302){
		$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false);
		
		// 输入内容合法，写cookie
		if ( $is_IIS ) {
			header("Refresh: 0;url=$location");
		} else {
			header("Location: $location", true, $status);
		}
	}

function site_die( $message, $backurl=null, $title = '发生错误' ) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono -->
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $title ?></title>

<style type="text/css">
html{
	background: #F7F7F7;
}
body{
	background: white;
	color: #333;
	margin: 2em auto 0 auto;
	width: 700px;
	padding: 1em 2em;
	-moz-border-radius: 11px;
	-khtml-border-radius: 11px;
	-webkit-border-radius: 11px;
	border-radius: 11px;
	border: 1px solid #DFDFDF;
}

#error-page {
	margin-top: 50px;
}

#error-page p {
	font-size: 12px;
	line-height: 18px;
	margin: 25px 0 20px;
}

#error-page code {
	font-family: Consolas, Monaco, Courier, monospace;
}

</style>

</head>
<body id="error-page">
	
	<?php 
	echo "<p>发生错误:</p><p>".$message."</p>"; 
	if( isset($backurl) )
		echo '<p><a href="'.$backurl.'">点此返回</p>';
	else
		echo "\n<p><a href='javascript:history.back()'>点此返回</p>";
	?>
</body>
</html>
<?php
	die();
}
?>